import { getHistoricalHtml } from "@/services/weather";
import { defineStore } from "pinia";

const useHistoricalStore = defineStore("historical", {
  state: () => ({
    today: {},
    yesterday: [],
    statsByMonth: [],
    rain: {},
    hum: [],
  }),
  actions: {
    async fetchHistoricalData(city, code) {
      const res = await getHistoricalHtml(city, code);
      this.yesterday = res.historicalYesterday;
      this.today = res.historicalToday;
      this.statsByMonth = res.historicalStatsByMonth;
      this.rain = res.historicalRain;
      this.hum = res.historicalHum;
    },
  },
});

export default useHistoricalStore;
